package com.sharp.oss.dao.repository;

import com.sharp.kernel.constant.db.SqlConstant;
import com.sharp.kernel.mybatis.repository.BaseMysqlRepository;
import com.sharp.oss.dao.entity.SaBanner;
import com.sharp.oss.dao.mapper.SaBannerDao;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import javax.annotation.Resource;
import java.util.List;

/**
 * Title: SaBannerService
 * Description: Copyright: Copyright (c) 2019 Company: BHFAE
 *
 * @author Sharp
 * @date 2020/7/20 22:46
 * @description Project Name: Seed
 * @Package: com.srct.service.oss.dao.repository
 */
@Service
public class SaBannerService extends BaseMysqlRepository<SaBanner, SaBannerDao> {

    @Resource
    private SaBannerDao saBannerDao;

    public List<SaBanner> getAllBanner(Integer bannerType) {
        Example example = super.getExample();
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("type", bannerType);
        criteria.andEqualTo("valid", SqlConstant.VALID);
        example.orderBy("displayOrder").asc();
        return super.select(example);
    }

    public int countAllBanner(Integer bannerType) {
        Example example = super.getExample();
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("type", bannerType);
        criteria.andEqualTo("valid", SqlConstant.VALID);
        return super.count(example);
    }

    @Override
    protected SaBannerDao getDao() {
        return saBannerDao;
    }
}





